package easy;

import java.util.HashMap;

/*
1507. 转变日期格式
解题思路：模拟法
 */
public class LeeCode1507 {

  public String reformatDate(String date) {
    String [] months = new String[]{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
    HashMap<String, Integer> map = new HashMap<>();
    for (int i = 0; i < months.length; i++) {
      map.put(months[i],i+1);
    }
    String[] array = date.split(" ");
    int year = Integer.parseInt(array[2]);
    int month = map.get(array[1]);
    int day = Integer.parseInt(array[0].substring(0, array[0].length() - 2));
    return String.format("%d-%02d-%02d", year, month, day);
  }

  public static void main(String[] args) {
    System.out.println(new LeeCode1507().reformatDate("16th Jun 1933"));
  }
}
